<template>
  <div>
    <el-dialog
      v-model="dialogTableVisible"
      title="上报日志"
    >
      <el-table :data="tableData" v-loading="loading">
        <el-table-column property="dataValue" label="上报数据" />
        <el-table-column property="date" label="请求时间" />
        <!-- <el-table-column property="responseCode" label="错误代码" /> -->
        <el-table-column property="message" label="报错信息" />
      </el-table>
      <el-pagination
        layout="prev, pager, next, sizes"
        v-model:page-size="pagination.size"
        v-model:current-page="pagination.page"
        :total="pagination.total"
        @size-change="sizeChange"
        @current-change="pageChange"
        class="pagination"
      />
    </el-dialog>
  </div>
</template>

<script setup>
import { ref, reactive } from "vue";
import mitts from "@/utils/bus.js";
import { getLogInfo } from "@/api/systemLog/index";
import { ElMessage } from "element-plus";

const tableData = ref([]);
const dialogTableVisible = ref(false);
let rowData = reactive();
const loading = ref(false);
const pagination = reactive({
  page: 1,
  size: 10,
  total: 0,
});
mitts.on("visible", (e) => {
  dialogTableVisible.value = e;
});
mitts.on("dataId", (e) => {
  rowData = reactive(e);
  doDataList();
});
const doDataList = () => {
  loading.value = true;
  let data = {
    pageSize: pagination.size,
    pageNum: pagination.page,
    enterpriseCode:rowData.enterpriseCode,
    dataCode:rowData.dataCode,
    statDate:rowData.statDate
    // condition: JSON.stringify([
    //   { column: "remark4", type: "eq", value: id.value },
    // ]),
  };
  getLogInfo(data)
    .then((res) => {
      if (res.status == 200) {
        tableData.value = res.data.records;
        loading.value = false;
      } else {
        ElMessage.error("获取失败,请联系管理员！");
      }
    })
    .catch((msg) => {});
};
const sizeChange = (value) => {
  pagination.size = value;
  pagination.page = 1;
  doDataList();
};
/**
 * 页总数改变
 */
const pageChange = (value) => {
  pagination.page = value;
  doDataList();
};
</script>

<style lang="scss"></style>
